<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page 1</title>

<script src="//cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
<link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">
<script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<style>
</style>
<script>
</script>

</head>
<body>
<%
int counterInSession = session.getAttribute("counterInSession") != null? Integer.parseInt(String.valueOf(session.getAttribute("counterInSession"))): 0 ; 
int counterInApplication = application.getAttribute("counterInApplication") != null? Integer.parseInt(String.valueOf(application.getAttribute("counterInApplication"))): 0 ;
%>

<%
application.setAttribute("counterInApplication", ++counterInApplication);
session.setAttribute("counterInSession", ++counterInSession);
%>

<%
pageContext.setAttribute("var_in_page", "pageContext");
request.setAttribute("var_in_request", "request data.");
session.setAttribute("var_in_session", "session data.");
application.setAttribute("var_in_application", "application");
%>

<%
// request.getRequestDispatcher("test2.jsp").forward(request, response);
// response.sendRedirect("test2.jsp");
%>
counterInSession: <%=session.getAttribute("counterInSession") %><br>
counterInApplication: <%=application.getAttribute("counterInApplication") %>
</body>
</html>